package com.zut.eduservice.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zut.eduservice.entity.InformationSecurity;
import com.zut.eduservice.entity.Usertable;
import com.zut.eduservice.entity.excel.UserData;
import com.zut.eduservice.entity.vo.ClassInfo;
import com.zut.eduservice.listener.UserExcelListener;
import com.zut.eduservice.mapper.UsertableMapper;
import com.zut.eduservice.service.UsertableService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import com.alibaba.excel.EasyExcel;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author testjava
 * @since 2022-12-18
 */
@Service
public class UsertableServiceImpl extends ServiceImpl<UsertableMapper, Usertable> implements UsertableService {
    String classId=null;
    String classNmae=null;
    @Override
    public void saveUser(MultipartFile file, UsertableService usertableService,ClassInfo classInfo) {

        try {
            //文件输入流
            InputStream in = file.getInputStream();
            //调用方法进行读取
            EasyExcel.read(in, UserData.class,new UserExcelListener(usertableService,classId,classNmae)).sheet().headRowNumber(7).doRead();
        }catch(Exception e){
            e.printStackTrace();
        }
    }

    @Override
    public void page(Page<Usertable> pageInformation, QueryWrapper<InformationSecurity> wrapper) {

    }

    @Override
    public void deliverUser(ClassInfo classInfo) {
        classId=classInfo.getClassId();
        classNmae=classInfo.getClassName();
    }




}

